package com.zc.custom;

import jakarta.servlet.ServletContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.web.context.WebApplicationContext;

/**
 * @description:
 * @author: cong
 * @create: 2024/7/31
 */
@Slf4j
public class CustomServletContextListener implements ApplicationListener<ApplicationStartedEvent> {
    private ServletContext servletContext;
    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        WebApplicationContext applicationContext = (WebApplicationContext) event.getApplicationContext();
        log.info("CustomServletContextListener.onApplicationEvent监听了");
        this.servletContext = applicationContext.getServletContext();
    }

    @Override
    public boolean supportsAsyncExecution() {
        return ApplicationListener.super.supportsAsyncExecution();
    }
}
